package ch.electronet.wjw.index;

import java.util.HashSet;
import java.util.Set;

public class CounterVisitor implements NodeVisitor {

	private final Set result;

	public CounterVisitor() {
		this.result = new HashSet();
	}

	public void visit(Node node) {
		result.addAll(node.getData());
		for (Node child : node.getChildren()) {
			child.accept(this);
		}
	}

	public int count() {
		return result.size();
	}
}
